import Vue from 'vue'
import Router from 'vue-router'
import { Loading } from 'element-ui';

Vue.use(Router)

var router = new Router({
  routes: [
    {
      path: '/',
      name: 'home',
      component: require('@/view/home')
    },
    {
      path: '*',
      redirect: '/'
    },
    {
      path: '/setting',
      name: 'setting',
      component: require('@/view/set/set')
    },
    {
      path: '/apisync',
      name: 'apisync',
      component: require('@/view/main/apisync')
    }
  ]
});

var loadingInstance;
router.beforeEach(function (to, from, next) {
  loadingInstance = Loading.service({ fullscreen: true });
  next()
})

router.afterEach(function (to) {
  setTimeout(function(){
    loadingInstance.close();
  },100);
  
})

export default router
